
import java.awt.Image;

/**
 *
 * @author Billy
 */
public class Entity {
    private String name;
    private Image[] image;
    private int xPosition;
    private int yPosition;

    private int timer = 0;
    private int frameLength = 10; //default

    public Entity(){
        name = "NoName";
        image = null;
        xPosition = 0;
        yPosition = 0;
        Main.entityList.add(this);
    }
    public Entity(String name, int xPosition, int yPosition){
        this.name = name;
        this.image = null;
        this.xPosition = xPosition;
        this.yPosition = yPosition;
        Main.entityList.add(this);
    }
    public Entity(String name, int xPosition, int yPosition, Image[] image){
        this.name = name;
        this.image = image;
        this.xPosition = xPosition;
        this.yPosition = yPosition;
        Main.entityList.add(this);
    }
    public int getX(){
        return xPosition;
    }
    public int getY(){
        return yPosition;
    }
    public void setX(int x){
        xPosition = x;
    }
    public void setY(int y){
        yPosition = y;
    }
    public Image getImage(){
        if(image==null){
            return null;
        }
        timer++;
        if(timer>=frameLength*image.length){
            timer = 0;
        }
        return image[timer/frameLength];
    }
    public void remove(){
        name = "";
        image = null;
        xPosition = 0;
        yPosition = 0;
        Main.entityList.remove(this);
    }

    public void setFrameLength(int frameLength){
        this.frameLength = frameLength;
    }
}
